package com.shiro.services;

import java.util.Date;

import com.shiro.entity.ShiroUser;
import org.apache.shiro.SecurityUtils;


public class AbstractService {

	/**
	 * 取出Shiro中的当前用户.
	 */
	public ShiroUser getCurrentUser() {
		ShiroUser user = (ShiroUser) SecurityUtils.getSubject().getPrincipal();
		return user;
	}
	
	public String getCurrentUserName() {
		ShiroUser user = (ShiroUser) SecurityUtils.getSubject().getPrincipal();
		return user.getLoginName();
	}
	
	public String getCurrenUserId(){
		ShiroUser user = (ShiroUser) SecurityUtils.getSubject().getPrincipal();
		return user.getId();
	}
	

	public Date getCurrentDate(){
		return new Date();
	}
	

}